Skip to content

perf: use requestIdleCallback for prefetch and fix CLS layout shift - #127

Merged
therealsama merged 1 commit into
mainfrom
perf/idle-prefetch-and-cls-fix
May 30, 2026
Merged

therealsama merged 1 commit into
mainfrom
perf/idle-prefetch-and-cls-fix

Conversation

@therealsama

Copy link
Copy Markdown
Collaborator
  • Defer comment prefetching with requestIdleCallback (2s timeout fallback) to avoid competing with critical rendering and network requests
  • Gate load-more sentinel on stories.length > 0 to eliminate CLS 0.145 layout shift caused by sentinel rendering before content
  • Add requestIdleCallback/cancelIdleCallback stubs to test setup for Vitest fake-timer compatibility
  • Reorganize App.tsx imports for consistency

@therealsama
therealsama requested a review from kplachkov as a code owner May 30, 2026 15:26
@therealsama
therealsama enabled auto-merge May 30, 2026 15:29
@therealsama
therealsama force-pushed the perf/idle-prefetch-and-cls-fix branch from 9dca836 to 215fd48 Compare May 30, 2026 16:01
- Defer comment prefetching with requestIdleCallback (2s timeout fallback)
  to avoid competing with critical rendering and network requests
- Gate load-more sentinel on stories.length > 0 to eliminate CLS 0.145
  layout shift caused by sentinel rendering before content
- Remove route-level lazy/Suspense to eliminate loading-flash on navigation
  (+7KB gzip initial load; eliminates 12 chunk fetches on route transitions)
- Add requestIdleCallback/cancelIdleCallback stubs to test setup for
  Vitest fake-timer compatibility
@therealsama
therealsama force-pushed the perf/idle-prefetch-and-cls-fix branch from 215fd48 to 448d378 Compare May 30, 2026 16:14
@therealsama
therealsama merged commit c597e30 into main May 30, 2026
4 checks passed
@therealsama
therealsama deleted the perf/idle-prefetch-and-cls-fix branch May 30, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants